package com.ropeok.service.impl;
import com.ropeok.dao.UserRoleDao;
import com.ropeok.entity.UserRole;
import com.ropeok.service.RoleService;
import com.ropeok.service.UserRoleService;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @BelongsProject: task2
 * @BelongsPackage: com.ropeok.service
 * @Author: zhofeifan
 * @CreateTime: 2022-08-23  14:49
 * @Description: TODO
 * @Version: 1.0
 */
@Service("userRoleService")
public class UserRoleServiceImpl implements UserRoleService {
    private static Logger logger= LoggerFactory.getLogger(UserRoleService.class);
    @Autowired
    private UserRoleDao userRoleDao;
    /**
     * @description: 查询用户角色列表
     * @author: zhoufeifan
     * @date: 2022/9/15 10:31
     * @param: []
     * @return: java.util.List<com.ropeok.entity.UserRole>
    **/
    @Override
    public List<UserRole> getUserRoleList() {
        List<UserRole> userRoleList = userRoleDao.getUserRoleList();
        return userRoleList;
    }
    /**
     * @description: 增加用户角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:31
     * @param: [com.ropeok.entity.UserRole]
     * @return: int
    **/
    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int addUserRole(UserRole userRole) {
        int i = userRoleDao.addUserRole(userRole);
        return i;

    }
    /**
     * @description: 删除用户角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:31
     * @param: [long]
     * @return: int
    **/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteUserRole(long id) {
        return  userRoleDao.deleteUserRole(id);
    }
    /**
     * @description: 根据ID查询用户角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:32
     * @param: [long]
     * @return: com.ropeok.entity.UserRole
    **/

    @Override
    public UserRole findUserRoleByID(long id) {
        return userRoleDao.findUserRoleByID(id);
    }
    /**
     * @description: 更新用户角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:32
     * @param: [com.ropeok.entity.UserRole]
     * @return: int
    **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int updateUserRole(UserRole userRole) {
        return userRoleDao.updateUserRole(userRole);
    }
}
